//
//  YYEScoreView.m
//  YuYingEDU
//
//  Created by zl on 2018/4/2.
//  Copyright © 2018年 胡波. All rights reserved.
//

#import "YYEScoreView.h"

@implementation YYEScoreView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.5];
        
        UIImageView *imgView1 = [UIImageView imgViewWithframe:CGRectZero icon:@"弹窗1"];
//        imgView1.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:imgView1];
        imgView1.userInteractionEnabled = YES;
        self.imgView1 = imgView1;

        
        UILabel *remindLab = [UILabel labelWithframe:CGRectZero text:@"您的试卷已提交，老师批改后可在我的题库中查看得分。" font:[UIFont systemFontOfSize:17] textAlignment:NSTextAlignmentCenter textColor:@"#000000"];
        [self.imgView1 addSubview:remindLab];
        self.remindLab = remindLab;
        remindLab.numberOfLines = 0;
        
        UIButton *cancelBtn = [UIButton buttonWithframe:CGRectZero text:@"" font:nil textColor:@"#333333" backgroundColor:nil normal:@"关闭1" selected:nil];
        [self addSubview:cancelBtn];
        [cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
        self.cancelBtn = cancelBtn;
        
    }
    return self;
}

- (void)setImgName:(NSString *)imgName
{
    
    _imgName = imgName;
    self.imgView1.image = [UIImage imageNamed:@"imgName"];
}

- (void)setRemindText:(NSString *)remindText
{
    _remindText = remindText;
    self.remindLab.text = remindText;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.imgView1 makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.centerY);
        make.centerX.equalTo(self.centerX);
        make.size.equalTo(CGSizeMake(250, 229));
    }] ;
    
    [self.remindLab makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.imgView1.left).offset(21);
        make.right.equalTo(self.imgView1.right).offset(-21);
        make.top.equalTo(self.imgView1.top).offset(117);
//        make.size.equalTo(CGSizeMake(282, 260));
    }] ;
    
    [self.cancelBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.imgView1.right).offset(17);
        make.top.equalTo(self.imgView1.top).offset(11);
        make.size.equalTo(CGSizeMake(35, 35));
    }] ;
}

- (void)cancelAction
{
    [self removeFromSuperview];
}


@end
